package com.groupbuying.customer.controller;

import com.groupbuying.customer.domain.CustomerInStorkDO;
import com.groupbuying.customer.service.CustomerInStorkService;
import com.groupbuying.customer.utils.PageUtils;
import com.groupbuying.customer.utils.Query;
import com.groupbuying.customer.utils.apiresult.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 功能描述
 * @author 作者
 * @date 创建时间
 * @des 详细描述
 * @tar 调用方(客户端小程序,服务商小程序,store后台,admin后台,api内部调用)
 */

@RestController
@RequestMapping("/customerInStork")
public class CustomerInStorkController {
	@Autowired
	private CustomerInStorkService customerInStorkService;


	/**
	 * @api {get} /customerInStork/list  查询列表数据
	 * @apiExample
	 * author mayunfei
	 * tar 用于:TODO 未知调用方
	 * date 2019/10/31
	 * @apiGroup bus-customer
	 * @apiVersion 1.0.0
	 * @apiHeader {String} Authorization 用户授权token
	 * @apiParam {Map} params
	 * @apiSuccess {PageUtils} pageUtils
	 */
	@GetMapping("/list")
	public PageUtils list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);
		List<CustomerInStorkDO> customerInStorkList = customerInStorkService.list(query);
		int total = customerInStorkService.count(query);
		PageUtils pageUtils = new PageUtils(customerInStorkList, total);
		return pageUtils;
	}

	/**
	 * @api {post} /customerInStork/getAllInStore 在每次点击抽奖之前要先触 发此接口查询奖品库存
	 * @apiExample
	 * author mayunfei
	 * tar 用于:TODO 未知调用方
	 * date 2019/10/31
	 * @apiGroup bus-customer
	 * @apiVersion 1.0.0
	 * @apiHeader {String} Authorization 用户授权token
	 * @apiParam  null
	 * @apiSuccess {ApiResult} success:登录成功; failure:请求
	 * @apiSuccess {ApiResult}  failure:请求
	 * @apiSuccess {ApiResult}  access_token失败
	 */
	@PostMapping("/getAllInStore")
	public ApiResult getAllPrize(){
		return customerInStorkService.getAll();
	}
	
}
